var galleryIndex = 0;
function showGallery(i)
{
	var galleryLast = $("#gallery img").length-1;
	
	galleryIndex = i>=0 ? (i<=galleryLast ? i : 0) : galleryLast;
	$("#slide img")[0].src = $("#gallery img")[galleryIndex].src;
	
	$("#overlay").show();
	
	$('#overlay').on( {
		'click' : function() { hideGallery(); }
	} );
	
	$("#slide").show();
}

function hideGallery()
{
	galleryIndex = 0;
	$('#slide').hide();
	$("#overlay").hide();
}